<% returns_active = %[customer_returns return_authorizations].include?(controller_name) && !@order %>

<% if can?(:manage, Spree::CustomerReturn) || can?(:manage, Spree::ReturnAuthorization) %>
  <%= nav_item(Spree.t(:returns), spree.admin_customer_returns_path, icon: 'receipt-refund', active: returns_active) %>

  <%# Submenu for expanded sidebar (only shown when active) %>
  <% if returns_active %>
    <ul class="nav-submenu">
      <% if can?(:manage, Spree::ReturnAuthorization) %>
        <%= nav_item(Spree.t(:return_authorizations), spree.admin_return_authorizations_path) %>
      <% end %>
      <%= render_admin_partials(:returns_nav_partials) %>
    </ul>
  <% end %>

  <%# Submenu dropdown for collapsed sidebar (always rendered, shown on hover) %>
  <% if can?(:manage, Spree::ReturnAuthorization) %>
    <ul class="nav-submenu-dropdown d-none dropdown-container">
      <%= nav_item(Spree.t(:returns), spree.admin_customer_returns_path) %>

      <%= nav_item(Spree.t(:return_authorizations), spree.admin_return_authorizations_path) %>

      <%= render_admin_partials(:returns_nav_partials) %>
    </ul>
  <% end %>
<% end %>